Dough Git

clove/pkviewer

web/src/routes/manage/[systemId]/links/+page.server.ts

back to web/src/routes/manage/[systemId]/links

/* web/src/routes/manage/[systemId]/links/+page.server.ts */
import { error } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
import { manageApi, seg } from "$lib/server/api.ts";
import type { StoredSocial } from "$lib/types.ts";

export const load: PageServerLoad = async ({ params }) => {
  const stored = await manageApi.get<{ links: StoredSocial[] }>(
    `/manage/systems/${seg(params.systemId)}/socials`,
  );
  if (!stored.ok) error(404);
  return {
    links: stored.value.links.map((link) => ({
      platform: link.platform,
      label: link.label ?? "",
      url: link.url,
    })),
  };
};